import Vue from 'vue'
import Router from 'vue-router'
import CompetitonManagement from '@/components/CompetitonManagement.vue'
import PowerManagement from '@/components/PowerManagement.vue'
import SportsEquipmentManagement from '@/components/SportsEquipmentManagement.vue'
import UserManagement from '@/components/UserManagement.vue'
import LoginInterface from '@/components/LoginInterface.vue'
import OrderManagement from '@/components/OrderManagement.vue'
import Player from '@/components/Player.vue'
import MessageCentering from '@/components/MessageCentering.vue'
import WinnerCenter from '@/components/WinnerCenter.vue'
import { Message } from 'element-ui'
import Banner from '@/components/Banner.vue';
Vue.use(Router)

export const router= new Router({
  mode: 'history',
  routes: [
    {
      path:"",
      redirect:"/LoginInterface"
    },
    {
      path: '/LoginInterface',
      name: 'LoginInterface',
      component: LoginInterface
    },
    {
      path:'/home',
      name:'home',
      component:()=>import("@/views/homeview.vue"),
      children:[  {
        path: 'UserManagement',
        name: 'UserManagement',
        component: UserManagement,
        beforeEnter: (to, from, next) => {
          // 假设你有一个方法来检查用户是否登录
          const isLogged = checkUserLogin(); // 你需要实现这个函数
          if (isLogged) {
            next(); // 用户已登录，允许访问
          } else {
            next({ name: 'login' }); // 用户未登录，重定向到登录页面
          }
        }
      },
      {
        path: 'OrderManagement',
        name: 'OrderManagement',
        component: OrderManagement
      },
   
      {
        path: 'Player',
        name: 'Player',
        component: Player
      },
      {
        path: 'CompetitonManagement',
        name: 'CompetitonManagement',
        component: CompetitonManagement
      },
      {
        path: 'SportsEquipmentManagement',
        name: 'SportsEquipmentManagement',
        component: SportsEquipmentManagement
      },
   
    
      {
        path: 'PowerManagement',
        name: 'PowerManagement',
        component: PowerManagement,
    
      },
      {
        path: 'WinnerCenter',
        name: 'WinnerCenter',
        component: WinnerCenter
      },
      {
        path: 'MessageCentering',
        name: 'MessageCentering',
        component: MessageCentering
      },]
    }
 
    
  ]
})
export default router;